#include <myheader_c_plus.h>
#include <functional>
using std::ostream;
using std::function;
using std::cout;
using std::endl;
using std::vector;
class Point{
public:
    Point(int x)
    :_x(x)
    {

    }
     
    int getX()const
    {
        return _x;
    }


friend ostream & operator<<(ostream & os, const Point & rhs);

private:
    int _x;
};

ostream & operator<<(ostream & os, const Point & rhs)
{
    int x = rhs.getX();
    os << x;
    return os;
    
}
void test()
{
    // vector<int> vec = {1,2,3,5,3,264,4,254,23};
    vector<Point> vec = 
    {
        Point(1),
        Point(2),
        Point(3)
    };
    function<bool(Point & p1, Point & p2)> f_sort = [](Point & p1, Point & p2)->bool{
        if(p1.getX() > p2.getX()) return false;
        return true;
    };
    sort(vec.begin(), vec.end(),f_sort);
    for(auto & ele : vec)
    {
        cout << ele << " ";
    }
    cout << endl;
    function<void(Point&)> f = [](Point & point){
        int x = point.getX() + 1;
        cout << x << " ";
    };
    for_each(vec.begin(), vec.end(),f);
    
}
int main(int argc, char *argv[])
{
    test();
    return 0;
}

